var express = require('express');
var router = express.Router();
const { userModel } = require('../model/lsj_model')
const { chatshopModel, chatagentsModel } = require('../model/zjb_model')

// 获取所有用户
router.get("/getAllshop", async (req, res) => {
    const data = await chatshopModel.find({})
    res.send({
        code: 200,
        msg: "获取数据成功",
        data
    });
})
router.get("/getAllagents", async (req, res) => {
    const data = await chatagentsModel.find().populate("shop_id")
    res.send({
        code: 200,
        msg: "获取数据成功",
        data
    });
})
// 获取所有用户
router.get("/getAlluser", async (req, res) => {
    const data = await userModel.find({})
    let list = []
    data.forEach(i => {
        let obj = {
            id: i._id,
            name: i.name,
            password: i.password,
            avatar: i.author,
            email: i.email,
            phone: i.phone,
        }
        console.log(JSON.stringify(obj))
    })
    res.send({
        code: 200,
        msg: "获取数据成功",
        data
    });
})


module.exports = router;